Open up a webpage and return all the links.

//-- Usage
$f = file_get_contents("http://www.google.co.uk/");
$links = getLinks($f);
print_r($links);

=======================================================

function getLinks($f)
{
	preg_match_all("/<a\s[^>]*href=([\"\']??)([^\" >]*?)\\1[^>]*>(.*)<\/a>/siU", $f, $match, PREG_SET_ORDER);
	$total = count($match);
	$links = Array();
	for ( $i = 0; $i < $total; $i++ )
	{
		$link = $match[$i][0];
		$lurl = $match[$i][2];
		$text = $match[$i][3];

		$links[$i]['link'] = $link;
		$links[$i]['url']  = $lurl;
		$links[$i]['text'] = $text;
	}

	return $links;
}